﻿using Microsoft.Extensions.DependencyInjection.Extensions;
using Sino.CapacityCloud.Infrastructure.Services;
using Sino.CapacityCloud.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Extensions.DependencyInjection
{

    public static class BackgroundWorkerExtensions
    {

        public static void AddBackgroundWorker<TBackgroundWorkerService, TBackgroundWorkerImpl>(this IServiceCollection services)
            where TBackgroundWorkerService: class, IBackgroundWorker
            where TBackgroundWorkerImpl : class, TBackgroundWorkerService
        {
            if (services == null)
            {
                throw new ArgumentNullException("services");
            }
            services.TryAddEnumerable(ServiceDescriptor.Singleton<TBackgroundWorkerService, TBackgroundWorkerImpl>());
        }

    }

}